package cn.iocoder.yudao.module.api.pay.wechat.enums;

import cn.iocoder.yudao.framework.business.basic.enums.EnumValuable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 微信支付单状态枚举
 *
 * @author 山野羡民
 */
@Getter
@AllArgsConstructor
public enum WechatOrderStatusEnum implements EnumValuable {

    PENDING(0, "待处理"),
    PAID(1, "待发货"),
    SHIPPED(2, "已发货"),
    CONFIRMED(3, "已收货"),
    COMPLETED(4, "已完成"),
    REFUNDED(5, "已退款"),
    SETTLEMENT(6, "待结算"),
    ERROR(99, "出错"),
    ;

    @EnumValue
    private final Integer value;
    private final String name;

    public static WechatOrderStatusEnum valueOf(int value) {
        return Stream.of(WechatOrderStatusEnum.values())
                .filter(p -> p.value == value)
                .findAny()
                .orElse(PENDING);
    }


}
